package com.jiayang.hhotel.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jiayang.hhotel.R;
import com.jiayang.hhotel.bean.ContactPersonModel;
import com.yanzhenjie.recyclerview.swipe.SwipeMenuAdapter;

import java.util.List;

/**
 * Created by Administrator on 2017/5/16 0016.
 * 联系人列表适配器
 */

public class ContactPersonListAdapter extends SwipeMenuAdapter<ContactPersonListAdapter.ViewHolder> {

//    private static final int TYPE_ITEM =0; //普通Item View
//    private static final int TYPE_FOOTER = 1; // 底部FootView

    private Context t;
    private List<ContactPersonModel> mList;

    public ContactPersonListAdapter(Context context, List<ContactPersonModel> list ){
        this.mList=list;
        this.t=context;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        ContactPersonModel model = mList.get(position);
        holder.name.setText(model.getName());
        holder.department.setText(model.getDepartment());
        holder.canUse.setText(model.getCanUse());
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    @Override
    public View onCreateContentView(ViewGroup parent, int viewType) {
        return LayoutInflater.from(t).inflate(R.layout.contact_person_list_item, parent, false);
    }

    @Override
    public ViewHolder onCompatCreateViewHolder(View realContentView, int viewType) {
        return new ViewHolder(realContentView);
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        TextView name;//名字
        TextView department;//部门
        TextView canUse;//能否使用协议价

        public ViewHolder(View convertView) {
            super(convertView);
            name= (TextView) convertView.findViewById(R.id.tv_name);
            department= (TextView) convertView.findViewById(R.id.tv_department);
            canUse= (TextView) convertView.findViewById(R.id.tv_can_use);
        }
    }
}
